import { NextApiRequest, NextApiResponse } from "next";
import { initORM } from "../../../utils/orm";
import { User } from "../../../entities/User";
import { getConfig, getCurrentUser, getUser } from "@/services";

async function getConfigDetail(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  const appResult = await getConfig(req);
  if (!appResult.success) {
    res.status(400).json(appResult);
    return;
  }

  res.status(200).json(appResult);
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  if (req.method === "GET") {
    getConfigDetail(req, res);
  } else {
    res.status(405).json({
      success: false,
      data: {},
      message: "Method not allowed",
    });
  }
}
